﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MarvellousWorks.PracticalPattern.FactoryMethod.Batch
{
    public abstract class DirectorBase
    {
        protected IList<DecisionBase> decisions = new List<DecisionBase>();

        // 实际项目中最好将每个 Director 需要添加的 Decision 定义在配置文件中，
        // 这样新增加的 Decision 项都在后台完成，而不需要 Assembler 显式调用该方法补充
        protected virtual void Insert(DecisionBase decision)
        {
            if ((decision == null) || (decision.Factory == null) || (decision.Quantity < 0))
            {
                throw new ArgumentException("decision");
            }
            decisions.Add(decision);
        }

        // 便于客户程序使用增加的迭代器
        public virtual IEnumerable<DecisionBase> Decisions { get { return decisions; } }
    }
}
